<?php

namespace Cck\ArticlesSystem\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class SettingResource extends JsonResource
{
    public function toArray($request)
    {
        if (!$this->resource) {
            return [];
        }

        $result = $this->resource->toArray();

        $result['group'] = $this->whenLoaded('group', function () {
            return new SettingGroupResource($this->resource->group);
        });

        return $result;
    }
}
